#!/bin/bash
echo "+---------------------+"
echo "NAM Uninstaller for Mac"
echo "+---------------------+"
sleep 4
clear
if [ ! -f /usr/NAMDir-5cu24bN ]
then
	echo "The NAM uninstaller file (/usr/NAMDir-5cu24bN) was not found. The NAM may not be installed, or the user installing the NAM did not have privileges to write in /usr"
	sleep 4
	exit
fi
echo "Are you sure you want to uninstall the NAM? [y/N]"
read choice

while [ ! "${choice}" = "y" ] && [ ! "${choice}" = "Y" ] && [ ! "${choice}" = "n" ] && [ ! "${choice}" = "N" ]
do
	echo "Invalid choice. Type y to uninstall the NAM or n to exit."
	read choice
done

if [ "${choice}" = "y" ] || [ "${choice}" = "Y" ]
then
	while read directory
	do
		echo "Removing the NAM from ${directory}/NAM ..."
		rm -rf "${directory}/NAM"
		echo "Done."
		sleep 5
		exit
	done < /usr/NAMDir-5cu24bN
else
	exit
fi
